/**
 * File : ZpJedisCluster.java <br/>
 * Author : lenovo <br/>
 * Version : 1.1 <br/>
 * Date : 2017年2月14日 <br/>
 * Modify : <br/>
 * Package Name : com.zhongpin.zz.redis.jfinal.plugin.cluster <br/>
 * Project Name : zp-zz-redis <br/>
 * Description : <br/>
 * 
 */

package com.redis.jfinal.plugin.cluster;

import java.util.Collections;
import java.util.Set;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;

/**
 * ClassName : ZpJedisCluster <br/>
 * Function : 自定义 JedisCluster ， 可以增加自定义方法. <br/>
 * Reason : 自定义 JedisCluster ， 可以增加自定义方法. <br/>
 * Date : 2017年2月14日 下午2:39:41 <br/>
 * 
 * @author : alexgaoyh <br/>
 * @version : 1.1 <br/>
 * @since : JDK 1.6 <br/>
 * @see
 */

public class ZpJedisCluster extends JedisCluster {

	public static enum Reset {
		SOFT, HARD
	}

	public ZpJedisCluster(HostAndPort node) {
		this(Collections.singleton(node), DEFAULT_TIMEOUT);
	}

	public ZpJedisCluster(HostAndPort node, int timeout) {
		this(Collections.singleton(node), timeout, DEFAULT_MAX_REDIRECTIONS);
	}

	public ZpJedisCluster(HostAndPort node, int timeout, int maxAttempts) {
		this(Collections.singleton(node), timeout, maxAttempts, new GenericObjectPoolConfig());
	}

	public ZpJedisCluster(HostAndPort node, final GenericObjectPoolConfig poolConfig) {
		this(Collections.singleton(node), DEFAULT_TIMEOUT, DEFAULT_MAX_REDIRECTIONS, poolConfig);
	}

	public ZpJedisCluster(HostAndPort node, int timeout, final GenericObjectPoolConfig poolConfig) {
		this(Collections.singleton(node), timeout, DEFAULT_MAX_REDIRECTIONS, poolConfig);
	}

	public ZpJedisCluster(HostAndPort node, int timeout, int maxAttempts, final GenericObjectPoolConfig poolConfig) {
		this(Collections.singleton(node), timeout, maxAttempts, poolConfig);
	}

	public ZpJedisCluster(HostAndPort node, int connectionTimeout, int soTimeout, int maxAttempts, final GenericObjectPoolConfig poolConfig) {
		super(Collections.singleton(node), connectionTimeout, soTimeout, maxAttempts, poolConfig);
	}

	public ZpJedisCluster(HostAndPort node, int connectionTimeout, int soTimeout, int maxAttempts, String password, final GenericObjectPoolConfig poolConfig) {
		super(Collections.singleton(node), connectionTimeout, soTimeout, maxAttempts, password, poolConfig);
	}

	public ZpJedisCluster(Set<HostAndPort> nodes) {
		this(nodes, DEFAULT_TIMEOUT);
	}

	public ZpJedisCluster(Set<HostAndPort> nodes, int timeout) {
		this(nodes, timeout, DEFAULT_MAX_REDIRECTIONS);
	}

	public ZpJedisCluster(Set<HostAndPort> nodes, int timeout, int maxAttempts) {
		this(nodes, timeout, maxAttempts, new GenericObjectPoolConfig());
	}

	public ZpJedisCluster(Set<HostAndPort> nodes, final GenericObjectPoolConfig poolConfig) {
		this(nodes, DEFAULT_TIMEOUT, DEFAULT_MAX_REDIRECTIONS, poolConfig);
	}

	public ZpJedisCluster(Set<HostAndPort> nodes, int timeout, final GenericObjectPoolConfig poolConfig) {
		this(nodes, timeout, DEFAULT_MAX_REDIRECTIONS, poolConfig);
	}

	public ZpJedisCluster(Set<HostAndPort> jedisClusterNode, int timeout, int maxAttempts, final GenericObjectPoolConfig poolConfig) {
		super(jedisClusterNode, timeout, maxAttempts, poolConfig);
	}

	public ZpJedisCluster(Set<HostAndPort> jedisClusterNode, int connectionTimeout, int soTimeout, int maxAttempts, final GenericObjectPoolConfig poolConfig) {
		super(jedisClusterNode, connectionTimeout, soTimeout, maxAttempts, poolConfig);
	}

	public ZpJedisCluster(Set<HostAndPort> jedisClusterNode, int connectionTimeout, int soTimeout, int maxAttempts, String password, final GenericObjectPoolConfig poolConfig) {
		super(jedisClusterNode, connectionTimeout, soTimeout, maxAttempts, password, poolConfig);
	}

	/**
	 * 自定义一些方法：
	 * 	比如形如sesseion有效期的功能，最近一次访问后，重新刷新有效期，毫秒为单位
	 * 功能：<br/>
	 *
	 * @author alexgaoyh
	 * @version 2017年2月14日 下午2:55:46 <br/>
	 */
	public String getex(final String key, final long time) {
		pexpire(key, time);
		return get(key);
	}

}
